package com.fowo.api.service.handleWork;

import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
import com.fowo.api.entity.ListingFather;
import com.fowo.api.mapper.ListingFatherMapper;
import com.fowo.api.model.listing.father.ListingFatherRelievePairAction;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

@Component
public class ListingFatherRelievePair implements ListingFatherRelievePairAction {
    @Resource
    private ListingFatherMapper listingFatherMapper;

    @Override
    public void run(Long id) throws Exception {
        new LambdaUpdateChainWrapper<>(listingFatherMapper)
                .set(ListingFather::getPairProduct, null)
                .set(ListingFather::getProductName, "")
                .set(ListingFather::getSku, "")
                .set(ListingFather::getClassify, null)
                .set(ListingFather::getBrand, null)
                .set(ListingFather::getPairStatus, false)
                .set(ListingFather::getPairUpdateTime, new Date())
                .set(ListingFather::getPairType, "")
                .eq(ListingFather::getId, id)
                .update();
    }
}
